#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
LL a, b, n, m;
int main()
{
	cin >> n >> m >> a >> b;
	LL ans1 = 0, ans2 = 0;
	/*if (a > b) {
		LL x = min(n / 2, m);
		LL z1 = n - 2 * x;
		LL z2 = m - x;
		ans1 = x * a + min(z1, z2 / 2) * b;
	}
	else {
		LL x = min(n, m / 2);
		LL z1 = n - x;
		LL z2 = m - 2 * x;
		ans2 = x * b + min(z1 / 2, z2) * a;
	}
	cout << max(ans1, ans2) << endl;*/
	LL ans = 0;
	for (int i = 0; i <= min(n / 2, m); i++) {
		int x = n - i * 2;
		int y = m - i;
		ans = max(ans, i * a + min(x, y / 2) * b);
	}
	cout << ans << endl;
	return 0;
}